<template>
  <page-layout :avatar="currUser.name" style="margin-top: 5px">
    <div slot="headerContent">
      <div class="title">{{ msg }}，{{ currUser.name }}</div>
      <div>搬砖工程师 | 粤为科技 - 前端搬砖部</div>
    </div>
    <template>
      <a-row style="margin: 0 40px 0 10px">
        <a-col
          class="left-wrapper"
          :xl="24"
          :lg="24"
          :md="24"
          :sm="24"
          :xs="24"
        >
        <!-- 任务数据框 -->
          <a-card
            :class="{ 'project-list': true, anim: animate == true }"
            style="margin-bottom: 24px"
            :bordered="false"
            title="任务情况"
            :body-style="{ padding: 0 }"
          >
            <a
              :href="`#/task/processing`"
              slot="extra"
              v-if="userInfo.permissions.task"
              >任务列表</a
            >
            <div style="background-color: #fff; padding: 20px">
              <a-row :gutter="16">
                <a-col :span="8">
                  <a-card
                    title="本月新增"
                    :bordered="false"
                    size="small"
                    :hoverable="true"
                  >
                    <p
                      style="
                        fontsize: 40px;
                        color: rgba(0, 0, 0, 0.85);
                        marginbottom: 16px;
                        fontweight: 500;
                      "
                    >
                      {{ taskNum.new_count }}
                    </p>
                  </a-card>
                </a-col>
                <a-col :span="8">
                  <a-card
                    title="正在进行"
                    :bordered="false"
                    size="small"
                    :hoverable="true"
                  >
                    <!-- <p v-if="requirementNum.new_count">{{requirementNum.new_count}}</p> -->
                    <p
                      style="
                        fontsize: 40px;
                        color: rgba(0, 0, 0, 0.85);
                        marginbottom: 16px;
                        fontweight: 500;
                      "
                    >
                      {{ taskNum.doing_count }}
                    </p>
                  </a-card>
                </a-col>
                <a-col :span="8">
                  <a-card
                    title="总数"
                    :bordered="false"
                    size="small"
                    :hoverable="true"
                  >
                    <p
                      style="
                        fontsize: 40px;
                        color: rgba(0, 0, 0, 0.85);
                        marginbottom: 16px;
                        fontweight: 500;
                      "
                    >
                      {{ taskNum.total_count }}
                    </p>
                  </a-card>
                </a-col>
              </a-row>
              <br />
              <a-button
                type="link"
                style="margin-right: 10px"
                :href="`#/task/add?random=${random}`"
                v-if="userInfo.permissions.task_insert"
              >
                创建
              </a-button>
              <a-button
                type="link"
                style="margin-right: 10px; opacity: 0"
                v-else
              >
                创建
              </a-button>
              <a-button
                type="primary"
                style="margin-left: 210px; opacity: 0"
                :href="`#/task/processing`"
              >
                列表<a-icon type="right" />
              </a-button>
            </div>
          </a-card>
          
          <!-- 需求数据框 -->
          <a-card
            :class="{ 'project-list': true, anim: animate == true }"
            style="margin-bottom: 24px"
            :bordered="false"
            title="需求情况"
            :body-style="{ padding: 0 }"
          >
            <a
              :href="`#/demand/processing`"
              slot="extra"
              v-if="userInfo.permissions.requirements"
              >需求列表</a
            >
            <div style="background-color: #fff; padding: 20px">
              <a-row :gutter="16">
                <a-col :span="8">
                  <a-card
                    title="本月新增"
                    :bordered="false"
                    size="small"
                    :hoverable="true"
                    class="card-grid"
                  >
                    <p
                      style="
                        fontsize: 40px;
                        color: rgba(0, 0, 0, 0.85);
                        marginbottom: 16px;
                        fontweight: 500;
                      "
                    >
                      {{ requirementNum.new_count }}
                    </p>
                  </a-card>
                </a-col>
                <a-col :span="8">
                  <a-card
                    title="正在进行"
                    :bordered="false"
                    size="small"
                    :hoverable="true"
                  >
                    <!-- <p v-if="requirementNum.new_count">{{requirementNum.new_count}}</p> -->
                    <p
                      style="
                        fontsize: 40px;
                        color: rgba(0, 0, 0, 0.85);
                        marginbottom: 16px;
                        fontweight: 500;
                      "
                    >
                      {{ requirementNum.doing_count }}
                    </p>
                  </a-card>
                </a-col>
                <a-col :span="8">
                  <a-card
                    title="总数"
                    :bordered="false"
                    size="small"
                    :hoverable="true"
                  >
                    <p
                      style="
                        fontsize: 40px;
                        color: rgba(0, 0, 0, 0.85);
                        marginbottom: 16px;
                        fontweight: 500;
                      "
                    >
                      {{ requirementNum.total_count }}
                    </p>
                  </a-card>
                </a-col>
              </a-row>
              <br />
              <a-button
                type="link"
                style="margin-right: 10px"
                :href="`#/demand/add?random=${random}`"
                v-if="userInfo.permissions.requirements_insert"
              >
                创建
              </a-button>
              <a-button
                type="link"
                style="margin-right: 10px; opacity: 0"
                v-else
              >
                创建
              </a-button>
              <a-button
                type="primary"
                style="margin-left: 210px; opacity: 0"
                :href="`#/demand/processing`"
              >
                列表<a-icon type="right" />
              </a-button>
            </div>
          </a-card>
          
          <!-- 项目数据框 -->
          <a-card
            :class="{ 'project-list': true, anim: animate == true }"
            style="margin-bottom: 24px"
            :bordered="false"
            title="项目情况"
            :body-style="{ padding: 0 }"
          >
            <a
              :href="`#/project/index`"
              slot="extra"
              v-if="userInfo.permissions.projects"
              >项目列表</a
            >
            <div style="background-color: #fff; padding: 20px">
              <a-row :gutter="16">
                <a-col :span="8">
                  <a-card
                    title="本月新增"
                    :bordered="false"
                    size="small"
                    :hoverable="true"
                  >
                    <p
                      style="
                        fontsize: 40px;
                        color: rgba(0, 0, 0, 0.85);
                        marginbottom: 16px;
                        fontweight: 500;
                      "
                    >
                      {{ projectNum.new_count }}
                    </p>
                  </a-card>
                </a-col>
                <a-col :span="8">
                  <a-card
                    title="正在进行"
                    :bordered="false"
                    size="small"
                    :hoverable="true"
                  >
                    <!-- <p v-if="requirementNum.new_count">{{requirementNum.new_count}}</p> -->
                    <p
                      style="
                        fontsize: 40px;
                        color: rgba(0, 0, 0, 0.85);
                        marginbottom: 16px;
                        fontweight: 500;
                      "
                    >
                      {{ projectNum.doing_count }}
                    </p>
                  </a-card>
                </a-col>
                <a-col :span="8">
                  <a-card
                    title="总数"
                    :bordered="false"
                    size="small"
                    :hoverable="true"
                  >
                    <p
                      style="
                        fontsize: 40px;
                        color: rgba(0, 0, 0, 0.85);
                        marginbottom: 16px;
                        fontweight: 500;
                      "
                    >
                      {{ projectNum.total_count }}
                    </p>
                  </a-card>
                </a-col>
              </a-row>
              <br />

              <a-button
                type="link"
                style="margin-right: 10px"
                :href="`#/project/add?${random}`"
                v-if="userInfo.permissions.projects_insert"
              >
                创建
              </a-button>
              <a-button
                type="link"
                style="margin-right: 10px; opacity: 0"
                v-else
              >
                创建
              </a-button>
              <a-button
                type="primary"
                style="margin-left: 210px; opacity: 0"
                :href="`#/task/processing`"
              >
                列表<a-icon type="right" />
              </a-button>
            </div>
          </a-card>
          <!-- 产品数据框 -->
          <a-card
            :class="{ 'project-list': true, anim: animate == true }"
            style="margin-bottom: 24px"
            :bordered="false"
            title="产品情况"
            :body-style="{ padding: 0 }"
          >
            <a
              :href="`#/produce/index`"
              slot="extra"
              v-if="userInfo.permissions.produces_index"
              >产品列表</a
            >
            <div style="background-color: #fff; padding: 20px">
              <a-row :gutter="16">
                <a-col :span="8">
                  <a-card
                    title="本月新增"
                    :bordered="false"
                    size="small"
                    :hoverable="true"
                    style="width: "
                  >
                    <p
                      style="
                        fontsize: 40px;
                        color: rgba(0, 0, 0, 0.85);
                        marginbottom: 16px;
                        fontweight: 500;
                      "
                    >
                      {{ produceNum.new_count }}
                    </p>
                  </a-card>
                </a-col>
                <a-col :span="8">
                  <a-card
                    title="正在进行"
                    :bordered="false"
                    size="small"
                    :hoverable="true"
                  >
                    <!-- <p v-if="requirementNum.new_count">{{requirementNum.new_count}}</p> -->
                    <p
                      style="
                        fontsize: 40px;
                        color: rgba(0, 0, 0, 0.85);
                        marginbottom: 16px;
                        fontweight: 500;
                      "
                    >
                      0
                    </p>
                  </a-card>
                </a-col>
                <a-col :span="8">
                  <a-card
                    title="总数"
                    :bordered="false"
                    size="small"
                    :hoverable="true"
                  >
                    <p
                      style="
                        fontsize: 40px;
                        color: rgba(0, 0, 0, 0.85);
                        marginbottom: 16px;
                        fontweight: 500;
                      "
                    >
                      {{ produceNum.total_count }}
                    </p>
                  </a-card>
                </a-col>
              </a-row>
              <br />
              <a-button
                type="link"
                style="margin-right: 10px"
                :href="`#/project/add?${random}`"
                v-if="userInfo.permissions.produce_insert"
              >
                创建
              </a-button>
              <a-button
                type="link"
                style="margin-right: 10px; opacity: 0"
                :href="`#/project/add?${random}`"
                v-else
              >
                创建
              </a-button>
              <a-button
                type="primary"
                style="margin-left: 210px; opacity: 0"
                :href="`#/produce/index`"
              >
                列表<a-icon type="right" />
              </a-button>
            </div>
          </a-card>
        </a-col>

        <a-col style="" :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
          <a-card
            :class="{ 'project-list': true, anim: animate == true }"
            style="margin-bottom: 24px"
            :bordered="false"
            title="进行中"
            :body-style="{ padding: 0 }"
          >
            <a-tabs default-active-key="1">
              <a-tab-pane key="1" tab="任务">
                <a-table
                  :columns="task_columns"
                  :data-source="doingTask"
                  @change="onChange"
                  :loading="loading"
                  :pagination="task_pagination"
                  :scroll="{ y: 480 }"
                >
                  <div slot="truly_time" slot-scope="text, record">
                    <template v-if="text != null">
                      <a
                        style="text-decoration: underline"
                        @click="log_info(record.key)"
                        title="点击查看任务日志"
                      >
                        {{ text }}
                      </a>
                    </template>
                    <template v-else>
                      <a style="text-decoration: underline"> 暂未开始 </a>
                    </template>
                  </div>
                  <div slot="status" slot-scope="text">
                    <template v-if="text == 1">
                      <a-tag color="#2591FF"> 待开始 </a-tag>
                    </template>
                    <template v-else-if="text == 2">
                      <a-tag color="#FF6D25"> 进行中 </a-tag>
                    </template>
                    <template v-else-if="text == 3">
                      <a-tag color="#f5222d"> 超时 </a-tag>
                    </template>
                    <template v-else>
                      <a-tag color="#4E25FF"> 测试验收 </a-tag>
                    </template>
                  </div>
                </a-table>
              </a-tab-pane>
              <a-tab-pane key="2" tab="需求" force-render>
                <a-table
                  :columns="requirement_columns"
                  :data-source="doingRequirement"
                  @change="onChange_requirements"
                  :loading="loading"
                  :pagination="requirement_pagination"
                  :scroll="{ y: 480 }"
                >
                  <template slot="requirement_title" slot-scope="text, record">
                    <a
                      :href="`#/demand/detail?random=${random}&&id=${record.requirement_id}`"
                      >{{ text }}
                    </a>
                  </template>
                  <template slot="task_count" slot-scope="task_count, record">
                    <a
                      @click="task_infos(record.requirement_id)"
                      title="查看该需求下的任务的执行情况"
                    >
                      {{ task_count }}
                    </a>
                  </template>
                  <template slot="requirement_status" slot-scope="text">
                    <a-tag
                      :color="RequirementStatus[text ? text - 1 : 0].color"
                    >
                      {{ RequirementStatus[text ? text - 1 : 0].text }}
                    </a-tag>
                  </template>
                </a-table>
              </a-tab-pane>
              <a-tab-pane key="3" tab="项目">
                <a-table
                  :columns="project_columns"
                  :data-source="doingProject"
                  @change="onChange_project"
                  :loading="loading"
                  :pagination="project_pagination"
                  :scroll="{ y: 480 }"
                >
                  <div slot="team_names" slot-scope="text">
                    <a-tag color="blue" v-for="item in text" :key="item">
                      {{ item }}
                    </a-tag>
                  </div>
                  <div slot="introduce" slot-scope="text, record">
                    <a
                      class="introduce"
                      @click="lookIntroduce(text, record)"
                      href="javascript:;"
                    >
                      点击查看
                    </a>
                  </div>
                  <div slot="status" slot-scope="text">
                    <a-dropdown :trigger="['click']">
                      <a-tag :color="projectStatus[text ? text - 1 : 0].color">
                        {{ projectStatus[text ? text - 1 : 0].text }}
                      </a-tag>
                    </a-dropdown>
                  </div>
                </a-table>
              </a-tab-pane>
              <a-tab-pane key="4" tab="产品">
                <a-table
                  :columns="produce_columns"
                  :data-source="doingProduce"
                  @change="onChange_produce"
                  :loading="loading"
                  :pagination="produce_pagination"
                  :scroll="{ y: 480 }"
                >
                  <template slot="version_id" slot-scope="version_id">
                    <a-tag
                      v-if="version_id != null"
                      color="blue"
                    >
                      {{ version_id }}
                    </a-tag>
                    <a v-else style="color: gray">无版本</a>
                  </template>
                </a-table>
              </a-tab-pane>
            </a-tabs>
          </a-card>
        </a-col>
      </a-row>
    </template>
    <a-modal
      :footer="null"
      :destroyOnClose="true"
      v-model="task_visible"
      title="变更记录"
      ok-text="确认"
      @ok="hideModal"
      @cancel="hideModal"
      width="580px"
    >
      <a-table
        bordered
        :data-source="task_data"
        :columns="requirement_task_columns"
      >
        <template slot="haha" slot-scope="text, record">
          <a
            :href="`#/task/detail?random=${random}&&id=${record.task_id}`"
            @click="hideModal"
          >
            {{ text }}</a
          >
        </template>
      </a-table>
    </a-modal>
    <!-- 查看任务介绍弹窗 -->
    <a-modal
      :footer="null"
      :destroyOnClose="true"
      v-model="visible"
      title="任务记录"
      ok-text="确认"
      @ok="hideModal"
      @cancel="hideModal"
      width="580px"
    >
      <div v-html="introduceText"></div>
    </a-modal>
  </page-layout>
</template>
<script>
import PageLayout from "@/layouts/PageLayout";
import { tasks as demand_task } from "@/services/demand";
import { mapState } from "vuex";
import {
  doing_requirements,
  doing_task,
  getProjects,
  getProduces,
  projects,
  requirements,
  tasks,
  produces,
  status
} from "@/services/workPlace";

const requirement_columns = [
  {
    title: "需求名称",
    dataIndex: "title",
    // sorter: true,
    width: "15%",
    key: "title",
    scopedSlots: { customRender: "requirement_title" }
  },
  {
    title: "当前状态",
    dataIndex: "status",
    scopedSlots: { customRender: "requirement_status" },
    key: "status"
  },
  {
    title: "提交时间",
    dataIndex: "created_at",
    key: "created_at"
  },
  {
    title: "需求方",
    dataIndex: "author",
    key: "author"
  },
  {
    title: "负责人",
    dataIndex: "principal",
    key: "principal"
  },
  {
    title: "任务数",
    dataIndex: "task_count",
    key: "task_count",
    scopedSlots: { customRender: "task_count" }
  },
  {
    title: "关联项目",
    dataIndex: "project",
    key: "project"
  }
];
const requirement_task_columns = [
  {
    title: "ID",
    dataIndex: "task_id",
    scopedSlots: { customRender: "key" },
    key: "id",
    width: 55
    //   scopedSlots: { customRender: 'name' },
  },
  {
    title: "任务名称",
    dataIndex: "title",
    scopedSlots: { customRender: "haha" },
    key: "title"
  },
  {
    title: "工程师",
    dataIndex: "engineer",
    key: "engineer_id"
    // scopedSlots: { customRender: "files" },
  },
  {
    title: "开始时间",
    dataIndex: "started_at",
    key: "started_at"
    // ellipsis: true,
  },
  {
    title: "当前状态",
    dataIndex: "status",
    // scopedSlots: { customRender: "statu" },
    key: "status",
    align: "center"
  }
];
const task_columns = [
  {
    title: "ID",
    dataIndex: "task_id"
  },
  {
    title: "关联需求",
    dataIndex: "requirement_name"
  },
  {
    title: "任务名称",
    dataIndex: "title"
  },
  {
    title: "工程师",
    dataIndex: "engineer_name"
  },
  {
    title: "对接人",
    dataIndex: "docking_name"
  },
  {
    title: "任务状态",
    dataIndex: "status",
    scopedSlots: { customRender: "status" },
    key: "status"
  },
  {
    title: "总耗时",
    dataIndex: "truly_time",
    scopedSlots: { customRender: "truly_time" }
  }
];
const project_columns = [
  {
    title: "ID",
    dataIndex: "id",
    width: 60
  },
  {
    title: "所属部门",
    dataIndex: "department_name"
  },
  {
    title: "项目名称",
    dataIndex: "title"
  },

  {
    title: "创建者",
    dataIndex: "author_name"
  },
  {
    title: "开发团队",
    dataIndex: "team_names",
    scopedSlots: { customRender: "team_names" }
  },
  {
    title: "项目介绍",
    width: 200,
    dataIndex: "introduce",
    scopedSlots: { customRender: "introduce" }
  },
  {
    title: "项目开始时间",
    dataIndex: "start_time"
  },
  {
    title: "项目结束时间",
    dataIndex: "end_time"
  },
  {
    title: "项目状态",
    dataIndex: "status",
    scopedSlots: { customRender: "status" }
  }
];
const produce_columns = [
  {
    title: "ID",
    dataIndex: "id",
    width: 60
  },
  {
    title: "所属部门",
    dataIndex: "department_name",
    width: 100
  },

  {
    title: "产品名称",
    dataIndex: "name",
    width: 150
  },

  {
    title: "版本号",
    dataIndex: "version_id",
    scopedSlots: { customRender: "version_id" },
    width: 60
  },
  {
    title: "负责人",
    dataIndex: "author_name",
    width: 100
  },
  {
    title: "产品简介",
    width: 250,
    dataIndex: "summary",
    scopedSlots: { customRender: "summary" }
  },
  {
    title: "测试负责人",
    dataIndex: "test_name",
    width: 100
  },
  {
    title: "发布负责人",
    dataIndex: "deploy_name",
    scopedSlots: { customRender: "deploy_name" },
    width: 100
  }
];
export default {
  name: "WorkPlace",
  components: { PageLayout },
  data() {
    return {
      task_data: [],
      task_visible: false,
      task_columns,
      requirement_task_columns,
      requirement_columns,
      project_columns,
      produce_columns,
      msg: "",
      random: 0,
      animate: false,
      projectNum: "",
      taskNum: "",
      produceNum: "",
      requirementNum: "",
      doingRequirement: [], //进行中的需求
      requirement_pagination: {
        size: "small",
        showSizeChanger: true,
        showQuickJumper: true,
        poposition: "bottom",
        pageSize: 5,
        current: 1,
        total: 0
      },
      doingTask: [], //进行中的任务
      task_pagination: {
        size: "small",
        showSizeChanger: true,
        showQuickJumper: true,
        poposition: "bottom",
        pageSize: 5,
        current: 1,
        total: 0
      },
      doingProject: [], //进行中的项目
      project_pagination: {
        size: "small",
        showSizeChanger: true,
        showQuickJumper: true,
        poposition: "bottom",
        pageSize: 5,
        current: 1,
        total: 0
      },
      project_status: [],
      visible: false,
      introduceText: "",
      title: "",
      projectStatus: [
        {
          color: "#2591FF",
          text: "项目立项"
        },
        {
          color: "#4E25FF",
          text: "需求调研"
        },
        {
          color: "#F56D25",
          text: "需求分析会议"
        },
        {
          color: "#FF6D25",
          text: "技术可行性分析",
          width: 400
        },
        {
          color: "blue",
          text: "分解任务"
        },
        {
          color: "blue",
          text: "开发阶段"
        },
        {
          color: "blue",
          text: "测试阶段"
        },
        {
          color: "yellowgreen",
          text: "项目验收"
        },
        {
          color: "#555",
          text: "维护"
        }
      ],
      doingProduce: [], //进行中的产品
      produce_pagination: {
        size: "small",
        showSizeChanger: true,
        showQuickJumper: true,
        poposition: "bottom",
        pageSize: 5,
        current: 1,
        total: 0
      },
      loading: true,
      RequirementStatus: [
        {
          color: "#2591FF",
          text: "待审核"
        },
        {
          color: "#4E25FF",
          text: "排期中"
        },
        {
          color: "#FF6D25",
          text: "处理中"
        },
        {
          color: "yellowgreen",
          text: "待验收"
        }
      ]
    };
  },

  computed: {
    ...mapState("account", { currUser: "user" }),
    ...mapState("setting", ["lang", "avatarColor"])
  },
  activated() {
    this.random = Math.random();
  },
  created() {
    //获取cookie中的数据
    let userInfo = JSON.parse(window.localStorage.getItem("admin.user"));
    this.userInfo = userInfo;
    this.creaetTimeString();
    // 项目总数
    projects().then((res) => {
      if (res.data.code === 20000) {
        this.projectNum = res.data.data ? res.data.data : 0;
      }
    });
    // 需求数
    requirements().then((res) => {
      if (res.data.code === 20000) {
        this.requirementNum = res.data.data;
      }
    });
    // 任务数
    tasks().then((res) => {
      if (res.data.code === 20000) {
        this.taskNum = res.data.data ? res.data.data : 0;
      }
    });
    // 未完成数
    produces().then((res) => {
      if (res.data.code === 20000) {
        this.produceNum = res.data.data ? res.data.data : 0;
      }
    });

    let requirement_pagination_pageSize = this.requirement_pagination.pageSize;
    let requirement_pagination_current = this.requirement_pagination.current;
    this.loadTableData_requirement({ limit: requirement_pagination_pageSize, page: requirement_pagination_current });

    let task_pagination_pageSize = this.task_pagination.pageSize;
    let task_pagination_current = this.task_pagination.current;
    this.loadTableData({ limit: task_pagination_pageSize, page: task_pagination_current });
    
    let project_pagination_pageSize = this.project_pagination.pageSize;
    let project_pagination_current = this.project_pagination.current;
    this.loadTableData_project({ limit: project_pagination_pageSize, page: project_pagination_current });
   
    let produce_pagination_pageSize = this.produce_pagination.pageSize;
    let produce_pagination_current = this.produce_pagination.current;
    this.loadTableData_produce({ limit: produce_pagination_pageSize, page: produce_pagination_current });

  },
  methods: {
    // 查看介绍详情关闭
    afterClose() {
      // 清除内容和title
      this.introduceText = "";
      this.title = "";
    },
    // 查看介绍详情
    lookIntroduce(text, record) {
      this.introduceText = text;
      this.visible = true;
      this.title = record.title;
    },
    hideModal(a) {
      this.task_visible = false;
      this.task_data = null;
    },
    task_infos(id) {
      this.getTasks(id);
      this.task_visible = true;
    },
    getTasks(id) {
      demand_task(id).then((res) => {
        if (res.data.code === 20000) {
          this.task_data = res.data.data;
        }
      });
    },
    onChange_requirements(e) {
      const { current, pageSize } = e;
      this.loadTableData_requirement({ limit: pageSize, page: current });
    },
    onChange(e) {
      const { current, pageSize } = e;
      this.loadTableData({ limit: pageSize, page: current });
    },
    onChange_project(e) {
      const { current, pageSize } = e;
      this.loadTableData_project({ limit: pageSize, page: current });
    },
    onChange_produce(e) {
      const { current, pageSize } = e;
      this.loadTableData_produce({ limit: pageSize, page: current });
    },
    // 请求table 的数据
    // obj 请求的字段
    loadTableData_requirement(obj) {
      this.loading = true;
      doing_requirements(obj).then((res) => {
        this.loading = false;
        if (res.data.code === 20000) {
          const { current_page, total, per_page } = res.data.data;
          Object.assign(this.requirement_pagination, {
            total: parseInt(total),
            current: parseInt(current_page),
            // pageSize: parseInt(per_page)
          });
          this.doingRequirement = res.data.data.data;
        }
      });
    },
    loadTableData(obj) {
      this.loading = true;
      doing_task(obj).then((res) => {
        this.loading = false;
        if (res.data.code === 20000) {
          const { current_page, total, per_page } = res.data.data;
          Object.assign(this.task_pagination, {
            total: parseInt(total),
            current: parseInt(current_page),
            pageSize: parseInt(per_page)
          });
          this.doingTask = res.data.data.data;
        }
      });
    },
    loadTableData_project(obj) {
      this.loading = true;
      getProjects(obj).then(
        (res) => {
          this.loading = false;
          if (res.data.code === 20000) {
            const { current_page, total, per_page } = res.data.data;
            Object.assign(this.project_pagination, {
              total: parseInt(total),
              current: parseInt(current_page),
              pageSize: parseInt(per_page)
            });
            this.doingProject = res.data.data.data;
          }
        },
        status().then((res) => {
          //获取项目状态
          if (res.data.code === 20000) this.project_status = res.data.data;
        })
      );
    },
    loadTableData_produce(obj) {
      this.loading = true;
      getProduces(obj).then(
        (res) => {
          this.loading = false;
          if (res.data.code === 20000) {
            const { current_page, total, per_page } = res.data.data;
            Object.assign(this.produce_pagination, {
              total: parseInt(total),
              current: parseInt(current_page),
              pageSize: parseInt(per_page)
            });
            this.doingProduce = res.data.data.data;
          }
        },
      );
    },
    // 时间段
    creaetTimeString() {
      let time = new Date().getHours();
      if (time >= 6 && time < 12) {
        this.msg = "早上好";
      } else if (time >= 12 && time < 17) {
        this.msg = "下午好";
      } else if (time >= 17 && time < 19) {
        this.msg = "傍晚好";
      } else if (time >= 19 && time < 22) {
        this.msg = "晚上好";
      } else if (time >= 22) {
        this.msg = "深夜好";
      } else {
        this.msg = "凌晨好";
      }
    }
  }
};
</script>

<style lang="less">
@import "index";
</style>
